import React,{useEffect} from 'react'
import * as echarts from 'echarts'

export default function ChartBar(props) {
  const {optionsData = null, id = 'default-id', width = 600, height = 200,title,seriesName} = props;
 
  useEffect(() => {
    let xdata=optionsData.xkey
    let ydata=optionsData.ykey
    //初始化echarts
    var myChart = echarts.init(document.getElementById(id))
    myChart.setOption({
      title: {
        text: title
      },
      tooltip: {},
      xAxis: {
        data: xdata
      },
      yAxis: {},
      series: [
        {
          name: seriesName,
          type: 'bar',
          data:ydata
        }
      ]
    });
  })
  return (
    <div id={id} style={{width: width, height: height}}>222</div>
  )
}
